Skip to content

fix(prerecorded): return transcript groups in input order - #305

Open
mayankbohradev wants to merge 1 commit into
AssemblyAI:masterfrom
mayankbohradev:fix/transcribe-group-input-order
Open

mayankbohradev wants to merge 1 commit into
AssemblyAI:masterfrom
mayankbohradev:fix/transcribe-group-input-order

Conversation

@mayankbohradev

Copy link
Copy Markdown
Contributor

What

The threaded Transcriber.transcribe_group / submit_group and TranscriptGroup.wait_for_completion now return their transcripts in input order.

Why

Both collected their futures in a set and iterated it. A set of futures iterates by hash, so a group came back in an arbitrary order and a caller could not match a transcript to the file it came from. Refs #79.

  • transcriber.transcribe_group(files)[i] did not correspond to files[i].
  • TranscriptGroup.get_by_ids(["a", "b"]) could come back as b, a.

AsyncTranscriber already returns its groups in input order.

How

  • The futures are kept in a list and read back in submission order.
  • Both methods still wait for every future before they read a result, so which errors propagate, and when, is unchanged.
  • An input whose request fails with an HTTP error is still left out of the group. The others keep their order.

Testing

  • 5 new tests. With master's source they failed in 20 of 20 runs; with the change they pass.
  • A fixture gives each future a small descending hash. A future's default hash is its memory address, so without the fixture a set could iterate in input order by chance and hide a regression.
  • Transcriber and group tests pass on Python 3.9, 3.11, 3.12 and 3.13, on the httpx 0.22 and 0.24 floors and on the pydantic 1.10 floor.
  • Full unit suite: 1038 passed. test_a_forked_child_does_not_share_the_parents_tts_connections fails on macOS on master too.
  • ruff 0.3.5 and mypy 1.5.1 pass as CI runs them.

Notes for reviewers

Transcriber.transcribe_group, submit_group and
TranscriptGroup.wait_for_completion collected their futures in a set
and iterated it, so a group came back in an arbitrary order.

The futures are now kept in a list and read in submission order. Both
still wait for every future before they read a result.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant